package com.bianguo.android.functiondemo.view.activity;

import android.support.annotation.Nullable;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.adapter.BasePagerAdapter;
import com.bianguo.android.functiondemo.utils.MLog;
import com.bianguo.android.functiondemo.view.fragment.HomeFragment;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import butterknife.BindView;
import butterknife.OnClick;

public class DesignActivity extends BaseActivity {

    @BindView(R.id.design_tab)
    TabLayout mTabLayout;
    @BindView(R.id.design_pager)
    ViewPager mViewPager;
    @BindView(R.id.design_tool_bar)
    Toolbar mToolbar;

    private ArrayList<String> tabTitles;
    private ArrayList<Fragment> fragments;
    private BasePagerAdapter pagerAdapter;

    @Override
    public int layoutId() {
        return R.layout.activity_design;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        fragments = new ArrayList<>();
        tabTitles = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            tabTitles.add("fragment" + i);
            fragments.add(HomeFragment.newInstance());
        }
        pagerAdapter = new BasePagerAdapter(getSupportFragmentManager(), tabTitles, fragments);
        mViewPager.setAdapter(pagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
        HashSet<String> mSet = new HashSet<>();
        mSet.add("item1");
        mSet.add("item1");
        for (String str : mSet) {
            MLog.mLog("str = " + str);
        }
    }

    @OnClick({R.id.design_float_button})
    public void onClickBk(View view) {
        switch (view.getId()) {
            case R.id.design_float_button:
                Snackbar.make(view, "Hello FloatingActionButton", Snackbar.LENGTH_LONG).show();
                break;
        }
    }
}
